dflash: read the confidence-head metadata key instead of only guessing - #126
Merged
Conversation
Cleanup, no behaviour change for any valid checkpoint. These files already write dflash.confidence_head, and nothing read it. The runtime inferred the same fact from whether markov_w1.weight was present. That works for a complete export, but the two can disagree, and when they do the model loads as plain DFlash and reads drafts one row late. Acceptance drops hard and nothing says why. This declares the key and cross-checks it against the tensors: if the metadata claims a confidence head and markov_w1.weight is absent, the load fails with a message that names the cause. The tensor remains the fallback when the key is absent, so older exports load exactly as before. Verified: - the real drafter is unchanged, 65.891% acceptance and mean length 3.58, the same as on the current prism-v7 tip - a synthetic GGUF that sets dflash.confidence_head with no markov_w1.weight now fails on load with the new message, instead of loading and drafting badly Not in this change: dflash.sample_from_anchor is still only honoured on the DSpark path, so the row offset and the confidence head are still coupled through one flag. Decoupling them needs the converter to write sample_from_anchor explicitly for both lineages, because its default of true is DSpark-shaped and applying it uniformly today would change DFlash behaviour.
There was a problem hiding this comment.
Pull request overview
Adds validation for DFlash confidence-head metadata while preserving tensor-based fallback for older checkpoints.
Changes:
- Registers the
dflash.confidence_headmetadata key. - Rejects incomplete DSpark exports missing
markov_w1.weight.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/models/dflash.cpp |
Reads and validates confidence-head metadata. |
src/llama-arch.h |
Declares the metadata key enum. |
src/llama-arch.cpp |
Maps the enum to its GGUF key. |
Suppressed comments (1)
src/models/dflash.cpp:132
- This only checks the
true/missing mismatch. If the key is explicitlyfalsewhilemarkov_w1.weightis present, the loader still treats the model as DSpark, so the metadata is neither preferred nor fully cross-checked as described. Reject the inverse mismatch too, while retaining tensor fallback only when the key is absent.
if (has_kv_confidence_head && kv_confidence_head && !markov_meta) {
throw std::runtime_error("dflash: metadata declares a confidence head, but markov_w1.weight is missing. "
"The export is incomplete; it would load as plain DFlash and read drafts one row late");
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cleanup and quality-of-life. No behaviour change for any valid checkpoint.
What
These files already write
dflash.confidence_head, and nothing read it. The runtime worked the same fact out from whethermarkov_w1.weightis present.That is fine for a complete export. The problem is when the two disagree. A DSpark checkpoint that lost its markov head loads as plain DFlash, reads drafts one row late, and acceptance falls off a cliff with nothing in the log to say why. That is the same failure #122 fixed for the CLI flag, still reachable through a bad export.
So: declare the key, read it, and cross-check it against the tensors. If the metadata claims a confidence head and
markov_w1.weightis absent, the load fails and the message names the cause. The tensor stays the fallback when the key is absent, so older exports load exactly as before.3 files, +14/-0.
Verification
dflash.confidence_headwith nomarkov_w1.weightnow fails on load with the new message. Before this change the same file loaded and drafted badly.Deliberately not in this change
dflash.sample_from_anchoris still only honoured on the DSpark path, so the row offset and the confidence head remain coupled through one flag. Decoupling them properly needs the converter to writesample_from_anchorexplicitly for both lineages first: its default istrue, which is DSpark-shaped, so honouring it uniformly today would change DFlash behaviour and break those models. Worth deciding together, since it spans the packing side.